const Mock = require('mockjs')
const menus = [
  {
    'id': 1,
    'title': '常用链接',
    'path': 'dashboard',
    'icon': 'dashboard',
    'parentId': 0,
    'ordinal': 0
  },
  {
    'id': 2,
    'title': '供应商',
    'path': 'supplier',
    'icon': 'table',
    'parentId': 0,
    'ordinal': 0
  },
  {
    'id': 3,
    'title': '任务',
    'path': 'task',
    'icon': 'table',
    'parentId': 0,
    'ordinal': 0
  },
  {
    'id': 4,
    'title': '账号密码',
    'path': 'account',
    'icon': 'table',
    'parentId': 0,
    'ordinal': 0
  }
]
const data = Mock.mock({
  'items|16': [{
    id: '@id',
    title: '@ctitle(4)',
    image: '@image(200x120,#409EFF,#FFF,Mock.js)'
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/menus/gettree',
    type: 'get',
    response: config => {
      const items = menus
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/vue-admin-template/menus/getimages' + '.*',
    type: 'get',
    response: config => {
      const params = config.url.split('?')[1]
      let param = 16
      if (params) {
        param = Number(params.split('=')[1])
      }
      const items = data.items.slice(0, param)
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  }
]
